package meta

import (
	"fmt"
	"strings"
)

type LangMeta struct {
	field      string //索引列列表
	exportType string //导出类型
}

func NewLangMeta(fileName string, metaDefine string) *LangMeta {
	parts := strings.Split(metaDefine, " ")
	var langMeta LangMeta
	langMeta.field = parts[1]
	if len(parts) > 2 {
		langMeta.exportType = parts[2]
	} else {
		langMeta.exportType = ""
	}
	return &langMeta
}

func (m *LangMeta) Field() string {
	return m.field
}

func (m *LangMeta) ExportType() string {
	return m.exportType
}

type LangMergeMeta struct {
	field   string //字段名
	mergeTo string //合并在那一个key中
	suffix  string //导出列的后缀
}

func NewLangMergeMeta(fileName string, metaDefine string) (*LangMergeMeta, error) {
	parts := strings.Split(metaDefine, " ")
	if len(parts) < 4 {
		return nil, fmt.Errorf("metaDefine error")
	}
	var langMeta LangMergeMeta
	langMeta.field = parts[1]
	langMeta.mergeTo = parts[2]
	langMeta.suffix = parts[3]
	return &langMeta, nil
}

func (m *LangMergeMeta) Field() string {
	return m.field
}

func (m *LangMergeMeta) MergoTo() string {
	return m.mergeTo
}

func (m *LangMergeMeta) Suffix() string {
	return m.suffix
}
